package cn.mcartoon.serviceImpl;
import cn.mcartoon.mapper.MmCartoonCollectionMapper;
import cn.mcartoon.pojo.MmCartoonCollection;
import cn.mcartoon.service.MmCartoonCollectionService;
import cn.mcartoon.dto.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.ArrayList;
import java.util.HashMap;
@Service
public class MmCartoonCollectionServiceImpl implements MmCartoonCollectionService {

    @Autowired
    private MmCartoonCollectionMapper mmCartoonCollectionMapper;

    public MmCartoonCollection getMmCartoonCollectionById(Long id){
        return mmCartoonCollectionMapper.getMmCartoonCollectionById(id);
    }

    public List<MmCartoonCollection>	getMmCartoonCollectionListByMap(Map<String,Object> param){
        return mmCartoonCollectionMapper.getMmCartoonCollectionListByMap(param);
    }

    public Integer getMmCartoonCollectionCountByMap(Map<String,Object> param){
        return mmCartoonCollectionMapper.getMmCartoonCollectionCountByMap(param);
    }

    public Integer insertMmCartoonCollection(MmCartoonCollection mmCartoonCollection){
            return mmCartoonCollectionMapper.insertMmCartoonCollection(mmCartoonCollection);
    }

    public Integer updateMmCartoonCollection(MmCartoonCollection mmCartoonCollection){
        return mmCartoonCollectionMapper.updateMmCartoonCollection(mmCartoonCollection);
    }

    public Integer deleteMmCartoonCollectionById(Long id){
        return mmCartoonCollectionMapper.deleteMmCartoonCollectionById(id);
    }

    public Integer batchDeleteMmCartoonCollection(String ids){
        Map<String,List<String>> param=new HashMap<String,List<String>>();
        String[] paramArrays=ids.split(",");
        List<String> idList=new ArrayList<String>();
            for (String temp:paramArrays){
                idList.add(temp);
            }
        param.put("ids",idList);
        return mmCartoonCollectionMapper.batchDeleteMmCartoonCollection(param);
    }

    public Page<MmCartoonCollection> queryMmCartoonCollectionPageByMap(Map<String,Object> param,Integer pageNo,Integer pageSize){
        Integer total = mmCartoonCollectionMapper.getMmCartoonCollectionCountByMap(param);
        Page page = new Page(pageNo, pageSize, total);
        param.put("beginPos", page.getBeginPos());
        param.put("pageSize", page.getPageSize());
        List<MmCartoonCollection> mmCartoonCollectionList = mmCartoonCollectionMapper.getMmCartoonCollectionListByMap(param);
        page.setList(mmCartoonCollectionList);
        return page;
     }


}
